<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="description" content="" />
        <meta name="keywords" content="" />
        <meta name="author" content="Flying hormone" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta charset="UTF-8">
        <link rel="stylesheet" href="../css/media.css" />
        <link rel="stylesheet" href="../css/mui.min.css" />
        <link rel="stylesheet" href="../css/head_foot.css" />
        <script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
        <script type="text/javascript" src="../js/jquery.Query.js" ></script>
        <script type="text/javascript" src="../js/jquery-cookie.js"></script>
        <script type="text/javascript" src="../js/mui.min.js"></script>
        <script type="text/javascript" src="../js/appcan.js"></script>
        <script type="text/javascript" src="../js/appcan.control.js"></script>
        <script type="text/javascript" src="../js/common.js" ></script>
		<title>同城搜列表</title>
		<style>
            
            .quyu{ position: relative; height: auto; overflow: hidden; font-size: 1em; line-height: 3em}
            #quyu{ height: auto; overflow: hidden;}
            #quyu>a{ font-size: 1em; display: block; border-bottom: 0.1em solid #ccc; padding: 0 2em 0 0.5em; color: #787878;
                height: 3em;
                width: 100%;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
            .quyu .quyu_zi{ }
            .quyu_zi a{ padding: 0.1em 0.5em; margin-right: 0.5em; margin-top: 0.5em; border-radius: 5px;background: #fff; color: #ff3366; border: 1px solid #ff3366;;
                display: inline-block;
                height: 1.6em;
                line-height: 1.4em; 
            }
            .quyu_zi .active{background: #ff3366; border-radius:0.1em; color: #fff; 
                display: inline-block;
                height: 1.6em;
                line-height: 1.4em; 
            }
            .xiangxia{ position: absolute; top: 1em; right: 0.625em; z-index: -100; }
            .tu_2 img{
                width: 100%;
                padding: 0.625em 1em;
                background: #fff;
            }
        </style>
	</head>

	<body>
		<header>
			<a><span class="leftleft"></span></a>
			<h1>同城搜列表</h1>
			<a class="xiaoxi4" href="javascript:;" onclick="openUrl('../user/add_message.html','add_message');">免费发布</a>
		</header>
		<section class="quyu">
            <div id="quyu">
                <a class="xianyin"></a>
                <span class="bottombottom xiangxia xianyin"></span>
                <div class="quyu_zi" style="display: none;padding: 0 0.5em;line-height: 2em;">
                    
                </div>
            </div>
        </section>
		<section class="same_city_search">
			<div>
				<ul class="list_e" id="messageList">
				</ul>
			</div>
		</section>

		<footer>
			<nav class="mui-bar mui-bar-tab">
				<a class="action" href="javascript:;" id="tcIndex">
                    <img src="../img/shouye.png" />
                    <span class="mui-tab-label">首页</span>
                </a>
                <a href="javascript:;" id="myfabu">
                    <img src="../img/fabu2.png" />
                    <span class="mui-tab-label">发布</span>
                </a>
                <a href="javascript:;" id="myInfo">
                    <img src="../img/mine.png" />
                    <span class="mui-tab-label">我的</span>
                </a>
			</nav>
		</footer>
        <script>
        $(document).ready(function(){
            appcan.ready(function(){
                appcan.window.setBounce({
                    bounceType:0,
                    startPullCall:function(type){
                    },
                    downEndCall:function(type){
                        window.location.reload();
                    },
                    upEndCall:function(type){
                        appcan.window.resetBounceView(type);
                    },
                    color:"#fff"
                })
            })
            //列表
            messageList("");
            //查询 分类
            appcan.ajax({
                type:"get",
                url:host+"/getAreaByName.json?cityName="+appcan.locStorage.getVal("ipcity"),
                dataType:"json",
                contentType: "application/json",
                success : function(dataResult) {
                    var actStr = '';
                    // 获取区域数据
                    for(var i=0;i<dataResult.data.length;i++){
                        actStr +='<a>'+dataResult.data[i].cityname+'</a>';
                    }
                    $(".quyu_zi").html(actStr);
                    if($(".quyu_zi .active").length ==0){
                        $("#quyu>a").text("请选择区域");
                    }
                    
                    // 绑定已选
                    var ccc = "";
                    for(var i=($(".quyu_zi .active").length); i>0; i--){
                       ccc = $(".quyu_zi .active").eq(i-1).text() + (ccc.length == 0 ? "" : ("," + ccc));
                       $("#quyu>a").text("区域："+ccc);
                    };
                    
                    // 选择事件
                    $(".xianyin").click(function(){
                       if($(".quyu_zi").css("display") == "none"){
                           $(".quyu_zi").show();
                       }else{
                           $(".quyu_zi").hide();
                       };
                    });
                    $(".quyu_zi a").click(function(){
                       if($(this).hasClass("active")){
                           $(this).removeClass("active");
                           $("#quyu>a").text(" ");
                           console.log($(".quyu_zi .active").length);
                           var ccc = "";
                           for(var i=($(".quyu_zi .active").length); i>0; i--){
                               ccc = $(".quyu_zi .active").eq(i-1).text() + (ccc.length == 0 ? "" : ("," + ccc));
                               $("#quyu>a").text("区域："+ccc);
                           };
                           if($(".quyu_zi .active").length ==0){
                               $("#quyu>a").text("请选择区域");
                               messageList("");
                           }else{
                               messageList(ccc);
                           };
                       }else{
                           $(".quyu_zi a").removeClass("active");
                           $(this).addClass("active");
                           $("#quyu>a").text(" ");
                           var ccc = "";
                           console.log($(".quyu_zi .active").length);
                           for(var i=$(".quyu_zi .active").length; i>0; i--){
                               ccc = $(".quyu_zi .active").eq(i-1).text() + (ccc.length == 0 ? "" : ("," + ccc));
                               $("#quyu>a").text("区域："+ccc);
                           };
                           if($(".quyu_zi .active").length ==0){
                               $("#quyu>a").text("请选择区域");
                               messageList("");
                           }else{
                               messageList(ccc);
                           };
                       }
                       $(".quyu_zi").hide();
                    });
                }
            })
        });
        function messageList (region) {
            var baseParam = {'addName':appcan.locStorage.getVal("ipcity"),'region':region}
            var param = serializePageJson(1,20,baseParam);
            appcan.ajax({
                type:"post",
                url:host+"/getMsgList.json",
                data:param,
                dataType:"json",
                contentType: "application/json",
                success : function(dataResult) {
                    var dataList = dataResult.data.dataList;
                    var magStr = "";
                    for(var i=0;i<dataList.length;i++){
                        magStr+='<li>';
                        magStr+='<a href="javascript:;" onclick="openUrl(\'info_msg.html?msgId='+dataList[i].id+'\',\'actinfomsg\');">';
                        magStr+='<div>';
                        magStr+='<img src="'+hostIp+dataList[i].picUrl+'" onerror="javascript:src=\'../img/lizi1.png\'">';
                        magStr+='</div>';
                        magStr+='<div><p>'+dataList[i].cardName;
                        magStr+='</p>'+dataList[i].title+'';
                        magStr+='<i>'+dataList[i].createTime+'</i>';
                        magStr+='</div></a></li>';
                    }
                    $("#messageList").html(magStr);
                }
            })
        }
        </script>
	</body>

</html>